perm filename WEAVE.CH2[WEB,ALS] blob
sn#671671 filedate 1982-08-05 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00002 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 @ Let us consider the big case statement for productions now, before looking
C00008 ENDMK
C⊗;
@ Let us consider the big case statement for productions now, before looking
at its context. We want to design the program so that this case statement
works, so we might as well not keep ourselves in suspense about exactly what
code needs to be provided with a proper environment.
The code here is more complicated than it need be, since some popular
\PASCAL\ compilers are unable to deal with procedures that contain a lot
of program text. The |translate| procedure, which incorporates the |case|
statement here, would become too long for those compilers if we did
not do something to split the cases into two parts. Therefore
a separate procedure called |five_cases| has been introduced.
@↑split procedures@>
This auxiliary procedure contains approximately half of the program text
that |translate| would have otherwise had. But even this division was not
sufficient and so the |alpha| case was also made into a separate procedure.
@<Match a production at |pp|, or increase |pp| if there is no match@>=
if cat[pp]<alpha then five_cases
else begin case cat[pp] of
alpha: alpha_cases;
case_head: @<Cases for |case_head|@>;
casey: @<Cases for |casey|@>;
clause: @<Cases for |clause|@>;
cond: @<Cases for |cond|@>;
elsie: @<Cases for |elsie|@>;
exp: @<Cases for |exp|@>;
mod_scrap: @<Cases for |mod_scrap|@>;
proc: @<Cases for |proc|@>;
record_head: @<Cases for |record_head|@>;
semi: @<Cases for |semi|@>;
stmt: @<Cases for |stmt|@>;
terminator: @<Cases for |terminator|@>;
var_head: @<Cases for |var_head|@>;
othercases do_nothing
endcases;@/
incr(pp); {if no match was found, we move to the right}
found: end
@z
@ Here is the procedure that needs to be present for the reason just
explained. Also included is the |alpha_cases| procedure.
@<Declaration of the |five_cases| procedure@>=
procedure five_cases; {a subprocedure of |translate|}
label found;
begin case cat[pp] of
beginning: @<Cases for |beginning|@>;
intro: @<Cases for |intro|@>;
math: @<Cases for |math|@>;
open: @<Cases for |open|@>;
simp: @<Cases for |simp|@>;
othercases do_nothing
endcases;@/
incr(pp); {if no match was found, we move to the right}
found: end;
procedure alpha_cases; {a subprocedure called in the above case statement}
label found;
begin @<Cases for |alpha|@>;
found: end;
@z